<template>
  <div v-if="isLoading" id="loading_container">
      <div class="loader"></div>
  </div>
</template>

<script setup>
  import { storeToRefs } from 'pinia'
  import { useLoadingStore } from '@src/stores/modules/loading'
  const loadingStore = useLoadingStore()
  const { isLoading } = storeToRefs(loadingStore)
</script>

<style scoped lang="scss">
#loading_container {
  z-index: 9999;
  width: 100%;
  position: fixed;
  height: 100%;
  background: rgba(0, 0, 0, .4);
  .loader {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
}
.loader {
  width: 90px;
  height: 14px;
  box-shadow: 0 3px 0 #fff;
  position: relative;
  display: grid;
  clip-path: inset(-60px 0 -5px)
}
.loader:after {
  content: "";
  position: relative;
  background: repeating-linear-gradient(90deg,#0000 0 calc(50% - 8px), #ccc 0 calc(50% + 8px), #0000 0 100%) 0 0/calc(100%/3) 100%;
  animation: l6-1 1s infinite;
} 
.loader:before {
  content: "";
  position: absolute;
  width: 14px;
  aspect-ratio: 1;
  left: calc(50% - 7px);
  bottom: 0;
  border-radius: 50%;
  background: lightblue;
  animation: l6-2 1s infinite;
}
@keyframes l6-1 {
  50%,100% {background-position: calc(100%/2) 0}
}
@keyframes l6-2 {
  0%,50% {transform:translateY(-80px)}
}
</style>